﻿@using Models.WebSite_HaiSheng
@model List<Article>
@Html.ActionLink("文章创建", "Create")
@*@(Html.Telerik().Grid<Article>().ClientEvents(e=>e.OnError("bindingError")).Name("Article").DataBinding(databinding => databinding.Ajax().Select("AjaxArticleIndex", "Article"))
                .DataKeys(keys =>
                {
                    keys.Add(s => s.ID);
                })
                .Columns(c =>
                {
                    c.Bound(item => item.Title).Width(200);
                    c.Bound(item => item.SubTitle).Width(200);
                    c.Bound(item => item.Pubulisher).Width(150);
                    c.Bound(item => item.PubulishTime).Width(150);
                    c.Bound(item => item.ArticleType).Width(200);
                    c.Bound(item => item.ID).Title("操作").ClientTemplate("<a href='/Article/edit/" + "<#= ID #>'>编辑</a> | <a href='/Article/details/" + "<#= ID #>'>详细</a>  | <a href='/Image/Create/?RelateType=Article&RelateId=" + "<#= ID #>'>添加图片</a>| <a href='/Article/delete/" + "<#= ID #>'>删除</a>"); 
                   })
                .DetailView(details => details.ClientTemplate(
                                        Html.Telerik().Grid<Image>().Name("Image<#= ID #>")
                                        .Columns(columns =>
                                        {
                                            columns.Bound(item => item.ImageName);
                                            columns.Bound(item => item.ImageUrl);
                                            columns.Bound(item => item.Description);
                                            columns.Bound(item => item.ID).Title("操作").ClientTemplate("<a href='/Image/edit/?RelateType=Article&id=" + "<#= ID #>'>编辑</a> | <a href='/Image/details/" + "<#= ID #>'>详细</a> | <a href='/Image/delete/?RelateType=Article&id=" + "<#= ID #>'>删除</a>");
            
                                        })
                                        .DataBinding(dataBinding => dataBinding.Ajax().Select("AjaxImageIndex", "Image", new {  RelateType = "Article", RelateId = "<#= ID #>" }))
                                        .Pageable().Sortable().Filterable().ToHtmlString()))
                .Resizable(resizing => resizing.Columns(true))
                .Pageable(p => p.PageSize(20))
                .Sortable()
                .Scrollable(scrolling => scrolling.Height(350))
)*@

@(Html.Telerik().Grid<Article>(Model).Name("Article")
                .DataKeys(keys =>
                {
                    keys.Add(s => s.ID);
                })
                .Columns(c =>
                {
                    c.Bound(item => item.Title).Width(200);
                    c.Bound(item => item.SubTitle).Width(200);
                    c.Bound(item => item.Pubulisher).Width(150);
                    c.Bound(item => item.PubulishTime).Width(150);
                    c.Bound(item => item.ArticleType).Width(200);
                    c.Bound(item => item.ID).Title("操作").Template(@<span>
                    <a href=@Url.Content("~/Article/Edit/" + item.ID) >编辑</a> | <a href=@Url.Content("~/Article/Details/" + item.ID)>详细</a>  | <a href=@Url.Content("~/Image/Create/?RelateType=Article&RelateId=" + item.ID)>添加图片</a>| <a href=@Url.Content("~/Article/delete/" + item.ID) >删除</a> 
                   </span>);
                })
                .DetailView(e => e.Template(
                        @<text>
                         @RenderGrid(item.GetImages(), item.ID)
                        </text>
                    ))
                .Resizable(resizing => resizing.Columns(true))
                .Pageable(p => p.PageSize(20))
                .Sortable()
                .Scrollable(scrolling => scrolling.Height(350))
                        )

@helper RenderGrid(List<Image> clients, int companyuid)
    { 
     @(Html.Telerik().Grid(clients).Name("images" + companyuid)
                            .Columns(c =>
                            {
                                c.Bound(item => item.ImageName);
                                c.Bound(item => item.ImageUrl);
                                c.Bound(item => item.Description);
                                c.Bound(item => item.ID).Title("操作").Template(@<span>
                    <a href=@Url.Content("~/image/Edit/" + item.ID) >编辑</a> | <a href=@Url.Content("~/image/Details/" + item.ID)>详细</a>  | <a href=@Url.Content("~/Image/delete/" + item.ID) >删除</a> 
                   </span>);
                            })
                                               .Resizable(resizing => resizing.Columns(true))
                                               .Pageable(p => p.PageSize(20))
                                               .Sortable())
} 